package server

import (
	"context"

	"starsine.cn/appTpl/svcapp/cmd"
	"starsine.cn/appTpl/svcpeers/svcpeersproto"
)

type SvcPeersServer struct {
	svcpeersproto.UnimplementedSvcPeersProtoServer
}

func (p *SvcPeersServer) SvcShakehand(ctx context.Context, in *svcpeersproto.ShakehandReq) (*svcpeersproto.ShakehandRes, error) {
	return &svcpeersproto.ShakehandRes{
		Succ: true,
	}, nil
}

func (p *SvcPeersServer) CmdLine(ctx context.Context, in *svcpeersproto.CmdLIneReq) (*svcpeersproto.CmdLIneRes, error) {
	out := cmd.CmdExec(in.CmdLine)

	return &svcpeersproto.CmdLIneRes{
		CmdLine: in.CmdLine,
		Out:     out,
	}, nil
}
